﻿using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using Microsoft.Commerce.Proxy.PaymentInstrumentService;

namespace TestWebApplication.CommercePaymentInstrument.APIs
{
    public class CommercePaymentInstrumentTestConnectionApi : CommercePaymentInstrumentApi
    {
        private string inputString;

        public CommercePaymentInstrumentTestConnectionApi(BasicHttpBinding binding, EndpointAddress address, X509Certificate2 clientCert, string inputString)
            : base(binding, address, clientCert)
        {
            this.inputString = inputString;
        }

        public string OutputString { get; private set; }

        protected override AbstractResponse ExecuteInternal(PaymentInstrumentServiceChannel channel)
        {
            this.OutputString = channel.TestConnection(this.inputString);

            return new AbstractResponse() 
            { 
                Ack = AckCodeType.Success,
            };
        }

        public override void PrepareRequestData()
        {
            // do nothing here
        }

        public override void PrepareResponseData()
        {
            // do nothing here
        }
    }
}
